package control

import (
	"sync"
)

// ControlMap 存储控制请求，以 key-value 对的形式
type ControlMap struct {
	m sync.Map
}

func NewControlMap() *ControlMap {
	return &ControlMap{}
}

func (c *ControlMap) Add(uuid string, channel chan interface{}) {
	c.m.Store(uuid, channel)
}

func (c *ControlMap) Get(uuid string) chan interface{} {
	if load, ok := c.m.Load(uuid); ok {
		return load.(chan interface{})
	}
	return nil
}

func (c *ControlMap) Delete(uuid string) {
	c.m.Delete(uuid)
}
